﻿using Microsoft.Practices.Prism.StoreApps;
using Microsoft.Practices.Prism.StoreApps.Interfaces;
using System;
using System.Windows.Input;

namespace WinRT.SIP.UILogic.ViewModels
{
    public class MainPageViewModel : ViewModel
    {
        private string _name;
        private string _greeting;

        public string Name
        {
            get { return _name; }
            set { SetProperty(ref _name, value); }
        }

        public string Greeting
        {
            get { return _greeting; }
            set { SetProperty(ref _greeting, value); }
        }

        public DelegateCommand GoBackCommand { get; private set; }
        public ICommand SayHelloCommand { get; private set; }

        public MainPageViewModel(INavigationService navigationService)
        {
            GoBackCommand = new DelegateCommand(navigationService.GoBack, navigationService.CanGoBack);

            SayHelloCommand = new DelegateCommand(() =>
                {
                    if (String.IsNullOrWhiteSpace(Name))
                    {
                        Greeting = null;
                    }
                    else
                    {
                        Greeting = "Hello, " + Name + "!";
                    }
                });
        }
    }
}
